← Back
Editing: gr_majority_loss_5_to_2_recovery.test
################################################################################ # Verify that a blocked group, a group with 5 members on which 3 do crash # (without executing STOP GROUP_REPLICATION), can be unblocked by DBA, even # when one member is recovering. # # Test: # 0) The test requires five servers: M1, M2, M3, M4 and M5. # 1) Bootstrap start a group on M1. Start GR on M3, M4, M5 to create a group # of 4 members and create a table on it. # 2) Only setup replication user and stop applier channel on M5, any member # that will try to recover from it will be blocked. # 3) Configure M2 to use replication user, so that it will be forced to # recover from M5, since it will not be able to authenticate on any other # member. # 4) Assert that M2 is blocked on recovery while fetching data from M5. # 5) Crash 3 members: M3, M4 and M5. # 6) Unblock the group with the alive member (M1). # 7) Configure replication user on M1 in order to allow M2 to recover from it. # 8) Assert check that group has 2 members on M1 and M2. # 9) Execute a transaction in order to prove liveness. # 10) Clean up. ################################################################################ # This test does crashes servers, thence we skip it on asan and valgrind. --source include/not_asan.inc --source include/not_valgrind.inc --source include/big_test.inc --source include/force_restart.inc --source ../inc/have_group_replication_plugin.inc --echo --echo ############################################################ --echo # 1. Create a group with 4 members and a table on it. --let $rpl_server_count= 5 --let $rpl_skip_group_replication_start= 1 --source ../inc/group_replication.inc --let $rpl_connection_name= server1 --source include/rpl_connection.inc --source ../inc/start_and_bootstrap_group_replication.inc --let $rpl_connection_name= server3 --source include/rpl_connection.inc --source include/start_group_replication.inc --let $member3_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) --let $rpl_connection_name= server4 --source include/rpl_connection.inc --source include/start_group_replication.inc --let $member4_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) --let $rpl_connection_name= server5 --source include/rpl_connection.inc --source include/start_group_replication.inc CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; --source include/rpl_sync.inc --let $member5_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) --echo --echo ############################################################ --echo # 2. Only setup replication user and stop applier channel --echo # on member 5, any member that will try to recover from --echo # it will be blocked. --let $rpl_connection_name= server5 --source include/rpl_connection.inc --let $server5_uuid= `SELECT @@GLOBAL.SERVER_UUID` --let $recovery_user= recovery_user --let $recovery_password= recovery_password SET SESSION sql_log_bin= 0; --eval CREATE USER "$recovery_user" IDENTIFIED BY "$recovery_password" --eval GRANT REPLICATION SLAVE ON *.* TO "$recovery_user" FLUSH PRIVILEGES; SET SESSION sql_log_bin= 1; STOP SLAVE SQL_THREAD FOR CHANNEL "group_replication_applier"; --let $wait_condition= SELECT service_state="OFF" FROM performance_schema.replication_applier_status WHERE channel_name="group_replication_applier" --source include/wait_condition.inc --echo --echo ############################################################ --echo # 3. Configure member 2 to use replication user, so that it --echo # will be forced to recover from member 5, since it will --echo # not be able to authenticate on any other member. --let $rpl_connection_name= server2 --source include/rpl_connection.inc --let $local_address_server2= `SELECT @@GLOBAL.group_replication_local_address` --disable_warnings --eval CHANGE MASTER TO MASTER_USER="$recovery_user", MASTER_PASSWORD="$recovery_password" FOR CHANNEL "group_replication_recovery" --enable_warnings SET SESSION sql_log_bin= 0; call mtr.add_suppression("There was an error when connecting to the donor server.*"); call mtr.add_suppression("For details please check performance_schema.replication_connection_status table and error log messages of Slave I/O for channel group_replication_recovery."); call mtr.add_suppression("Slave I/O for channel 'group_replication_recovery': Master command COM_REGISTER_SLAVE failed: Access denied for user 'recovery_user'.*"); call mtr.add_suppression("Slave I/O for channel 'group_replication_recovery': Master command COM_REGISTER_SLAVE failed: failed registering on master, reconnecting to try again.*"); call mtr.add_suppression("Slave I/O thread couldn't register on master"); call mtr.add_suppression("The member lost contact with a majority of the members in the group. Until the network is restored.*"); call mtr.add_suppression("The member resumed contact with a majority of the members in the group.*"); SET SESSION sql_log_bin= 1; SET @group_replication_recovery_reconnect_interval_saved= @@GLOBAL.group_replication_recovery_reconnect_interval; SET GLOBAL group_replication_recovery_reconnect_interval= 1; --disable_query_log --eval SET GLOBAL group_replication_group_name= "$group_replication_group_name" --enable_query_log --source include/start_group_replication_command.inc --echo --echo ############################################################ --echo # 4. Assert that member 2 is blocked on recovery while --echo # fetching data from member 5. --let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_connection_status WHERE channel_name="group_replication_recovery" AND service_state="ON" AND source_uuid="$server5_uuid"; --source include/wait_condition.inc --let $group_replication_member_state= RECOVERING --source ../inc/gr_wait_for_member_state.inc --echo --echo ############################################################ --echo # 5. Crash three members. # We do kill the servers, using shutdown_server 0, and then MTR will # follow the expect file and restart the sever, but we do not wait # for the server restart. # Since the servers loose its GCS configuration them will not rejoin # the group. --let $rpl_connection_name= server3 --source include/rpl_connection.inc --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.3.expect --shutdown_server 0 --source include/wait_until_disconnected.inc --let $rpl_connection_name= server4 --source include/rpl_connection.inc --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.4.expect --shutdown_server 0 --source include/wait_until_disconnected.inc --let $rpl_connection_name= server5 --source include/rpl_connection.inc --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.5.expect --shutdown_server 0 --source include/wait_until_disconnected.inc # Wait until all crashed members are detected. # server1 --let $rpl_connection_name= server1 --source include/rpl_connection.inc --let $i=5 while($i>2) { if ($i == 5) { --let $member_uuid= $member5_uuid } if ($i == 4) { --let $member_uuid= $member4_uuid } if ($i == 3) { --let $member_uuid= $member3_uuid } --let $group_replication_member_state= UNREACHABLE --let $group_replication_member_id= $member_uuid --source ../inc/gr_wait_for_member_state.inc --echo member$i @ server1 is marked as UNREACHABLE --dec $i } --let $group_replication_member_id= $member1_uuid --let $rpl_connection_name= server2 --source include/rpl_connection.inc --let $i=5 while($i>2) { if ($i == 5) { --let $member_uuid= $member5_uuid } if ($i == 4) { --let $member_uuid= $member4_uuid } if ($i == 3) { --let $member_uuid= $member3_uuid } --let $group_replication_member_state= UNREACHABLE --let $group_replication_member_id= $member_uuid --source ../inc/gr_wait_for_member_state.inc --echo member$i @ server2 is marked as UNREACHABLE --dec $i } --let $group_replication_member_id= $member2_uuid --echo --echo ############################################################ --echo # 6. Unblock the group with the alive members: server 1 and 2. --let $rpl_connection_name= server1 --source include/rpl_connection.inc --let $local_address_server1= `SELECT @@GLOBAL.group_replication_local_address` --disable_query_log --eval SET GLOBAL group_replication_force_members= "$local_address_server1,$local_address_server2" --enable_query_log --let $assert_text= group_replication_force_members is correct --let $assert_cond= "[SELECT @@GLOBAL.group_replication_force_members]" = "$local_address_server1,$local_address_server2" --source include/assert.inc --echo --echo ############################################################ --echo # 7. Configure replication user on member 1 in order to --echo # allow member 2 to recover from it. --let $rpl_connection_name= server2 --source include/rpl_connection.inc --let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_connection_status WHERE channel_name="group_replication_recovery" AND service_state="OFF"; --source include/wait_condition.inc --let $group_replication_member_state= RECOVERING --source ../inc/gr_wait_for_member_state.inc --let $rpl_connection_name= server1 --source include/rpl_connection.inc --eval CREATE USER "$recovery_user" IDENTIFIED BY "$recovery_password" --eval GRANT REPLICATION SLAVE ON *.* TO "$recovery_user" FLUSH PRIVILEGES; --let $rpl_connection_name= server2 --source include/rpl_connection.inc --let $wait_timeout= 120 --let $group_replication_member_state= ONLINE --source ../inc/gr_wait_for_member_state.inc SET @@GLOBAL.group_replication_recovery_reconnect_interval= @group_replication_recovery_reconnect_interval_saved; --echo --echo ############################################################ --echo # 8. Assert that group has 2 members: server 1 and 2. # Server 1 --let $rpl_connection_name= server1 --source include/rpl_connection.inc --let $group_replication_number_of_members= 2 --source ../inc/gr_wait_for_number_of_members.inc --let $server_uuid= `SELECT @@GLOBAL.SERVER_UUID` --let $assert_text= Server 1 must be present on group members --let $assert_cond= [SELECT COUNT(*) FROM performance_schema.replication_group_members WHERE member_id="$server_uuid"] = 1 --source include/assert.inc --let $raw_view_id= query_get_value(SELECT view_id FROM performance_schema.replication_group_member_stats, view_id, 1) --let $view_id= `SELECT RIGHT('$raw_view_id', 1)` --let $assert_text= The value of view_id must be random:6 --let $assert_cond= $view_id >= 6 --source include/assert.inc # Server 2 --let $rpl_connection_name= server2 --source include/rpl_connection.inc --let $group_replication_number_of_members= 2 --source ../inc/gr_wait_for_number_of_members.inc --let $server_uuid= `SELECT @@GLOBAL.SERVER_UUID` --let $assert_text= Server 2 must be present on group members --let $assert_cond= [SELECT COUNT(*) FROM performance_schema.replication_group_members WHERE member_id="$server_uuid"] = 1 --source include/assert.inc --let $raw_view_id= query_get_value(SELECT view_id FROM performance_schema.replication_group_member_stats, view_id, 1) --let $view_id= `SELECT RIGHT('$raw_view_id', 1)` --let $assert_text= The value of view_id must be random:6 --let $assert_cond= $view_id >= 6 --source include/assert.inc --echo --echo ############################################################ --echo # 9. Execute a transaction in order to prove liveness. --let $rpl_connection_name= server2 --source include/rpl_connection.inc INSERT INTO t1 VALUES (1); # We cannot use rpl_sync.inc because it will include servers 3, 4 and 5 # which are dead and will make rpl_sync.inc to fail. --let $sync_slave_connection= server1 --source include/sync_slave_sql_with_master.inc --let $assert_text= 'There is one value in table t1' --let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 1 --source include/assert.inc --let $diff_tables= server1:test.t1, server2:test.t1 --source include/diff_tables.inc --echo --echo ############################################################ --echo # 10. Clean up. --let $rpl_connection_name= server_3 --source include/rpl_connection.inc --let $rpl_server_number= 3 --source include/rpl_reconnect.inc --let $assert_text= 'There are no values in table t1' --let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 0 --source include/assert.inc DROP TABLE t1; --let $rpl_connection_name= server_4 --source include/rpl_connection.inc --let $rpl_server_number= 4 --source include/rpl_reconnect.inc --let $assert_text= 'There are no values in table t1' --let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 0 --source include/assert.inc DROP TABLE t1; --let $rpl_connection_name= server_5 --source include/rpl_connection.inc --let $rpl_server_number= 5 --source include/rpl_reconnect.inc --let $assert_text= 'There are no values in table t1' --let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 0 --source include/assert.inc DROP TABLE t1; --eval DROP USER "$recovery_user" FLUSH PRIVILEGES; --let $rpl_connection_name= server1 --source include/rpl_connection.inc DROP TABLE t1; --eval DROP USER "$recovery_user" FLUSH PRIVILEGES; SET SESSION sql_log_bin= 0; call mtr.add_suppression("The member lost contact with a majority of the members in the group. Until the network is restored.*"); call mtr.add_suppression("The member resumed contact with a majority of the members in the group.*"); SET SESSION sql_log_bin= 1; --source ../inc/group_replication_end.inc
Save File
Cancel